<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ad extends MY_Controller {
		
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		
		$this->tab = 'platform';
	}
	
	private function post_data(){		
		
		$data = array(
				'url'=>$this->input->post('url'),
				'webname'=>$this->input->post('webname'),
				'forder'=>$this->input->post('forder'),
				'desc'=>$this->input->post('desc'),
			);
		  		
		if($data['webname'] == ''){
			$ret['msg'] = '名称不能为空';
		}elseif($data['url'] == ''){
			$ret['msg'] = '链接地址不能为空';
		}elseif($data['desc'] == ''){
			$ret['msg'] = '合作伙伴描述不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
				
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_LINKS_IMG, LINKS_IMG,'links_');
		}else{
			$ret['msg'] = 'LOGO不能为空';
			exit;
		}
				
  		$data['logoimg'] 	= $thumbnail;
  		
  		return $data;
	}
	
	function add(){
		
  		$data = $this->post_data();
  		
  		$data['add_time'] 	= time();
  		$data['addip'] 		= $this->js->get_ip();
  		
  		$this->load->model('links_model');
  		$links_id = $this->links_model->add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][底部交换链接]['.$this->input->post('webname').']');
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function view($links_id){
		$this->load->model('links_model');
  		$links = $this->links_model->get_links_obj($links_id);
  		$vdata['links'] = $links;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'links';
		
  		$this->load->view("/sys_admin/site/links_view", $vdata);
	}
	
	function edit_view($links_id){
		$this->load->helper(array('form'));
		$this->load->model('links_model');
  		$links = $this->links_model->get_links_obj($links_id);
  		$vdata['links'] = $links;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'links';
		
  		$this->load->view("/sys_admin/site/links_edit", $vdata);
	}
	
	function edit(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_data();
		$blogoimg 		= $this->input->post('blogoimg');
  		$data['logoimg'] 	= $data['logoimg']?$data['logoimg']:$blogoimg;
  		
  		$this->load->model('links_model');
  		$links_id = $this->links_model->update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('修改][底部交换链接]ID=='.$id);
		
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function zhs_linkslist(){
		$this->load->model('links_model');
		$vdata = $this->links_model->get_links_list();
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
		$this->load->view('/sys_admin/site/links_list', $vdata);
	}
	
	function remove(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('links_model');
  		$this->load->model('log_model');$this->log_model->add_log('[删除][底部交换链接]');
		echo  $this->links_model->update($id, $data);
	}
	
	
	
}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ad extends MY_Controller {
    	
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		
		$this->tab = 'platform';
	}
	
	private function post_data(){		
		
		$data = array(
				'url'=>$this->input->post('url'),
				'webname'=>$this->input->post('webname'),
				'forder'=>$this->input->post('forder'),
				'desc'=>$this->input->post('desc'),
			);
		  		
		if($data['webname'] == ''){
			$ret['msg'] = '名称不能为空';
		}elseif($data['url'] == ''){
			$ret['msg'] = '链接地址不能为空';
		}elseif($data['desc'] == ''){
			$ret['msg'] = '合作伙伴描述不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
				
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_LINKS_IMG, LINKS_IMG,'links_');
		}else{
			$ret['msg'] = 'LOGO不能为空';
			exit;
		}
				
  		$data['logoimg'] 	= $thumbnail;
  		
  		return $data;
	}
	
	function add(){
		
  		$data = $this->post_data();
  		
  		$data['add_time'] 	= time();
  		$data['addip'] 		= $this->js->get_ip();
  		
  		$this->load->model('links_model');
  		$links_id = $this->links_model->add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][底部交换链接]['.$this->input->post('webname').']');
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function view($links_id){
		$this->load->model('links_model');
  		$links = $this->links_model->get_links_obj($links_id);
  		$vdata['links'] = $links;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'links';
		
  		$this->load->view("/sys_admin/site/links_view", $vdata);
	}
	
	function edit_view($links_id){
		$this->load->helper(array('form'));
		$this->load->model('links_model');
  		$links = $this->links_model->get_links_obj($links_id);
  		$vdata['links'] = $links;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'links';
		
  		$this->load->view("/sys_admin/site/links_edit", $vdata);
	}
	
	function edit(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_data();
		$blogoimg 		= $this->input->post('blogoimg');
  		$data['logoimg'] 	= $data['logoimg']?$data['logoimg']:$blogoimg;
  		
  		$this->load->model('links_model');
  		$links_id = $this->links_model->update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('修改][底部交换链接]ID=='.$id);
		
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function zhs_linkslist(){
		$this->load->model('links_model');
		$vdata = $this->links_model->get_links_list();
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = $this->sub;
		
		$this->load->view('/sys_admin/site/links_list', $vdata);
	}
	
	function remove(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('links_model');
  		$this->load->model('log_model');$this->log_model->add_log('[删除][底部交换链接]');
		echo  $this->links_model->update($id, $data);
	}
	
	
	
}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
